<?php
/**
 * Created by PhpStorm.
 * User: superxing-cto
 * Date: 17/3/2
 * Time: 10:51
 */

namespace App\Models;

/**
 * Class Interest
 * @property integer id
 * @property string title
 * @property string cover
 * @property boolean status
 * @property integer sort
 * @property string skill_ids
 */
class Interest extends ApplicationModel
{
    protected $fillable = [
        'title',
        'cover',
        'status',
        'sort',
        'skill_ids',
    ];

    public function scopeRelease($query)
    {
        return $query->where('status', true)->orderBy('sort', 'desc');
    }

    public function user_count()
    {
        return $this->userInterests()->count();
    }

    public function userInterests()
    {
        return $this->hasMany(UserInterest::class);
    }
}